#ifndef __NRF__
#define __NRF__

#include "spi_hal.h"
#define uchar unsigned char

/*******************************************************/
#define CONFIG 0x00
#define TX_DATA_WITDH 32//??????1???
#define RX_DATA_WITDH 32 	//??????1???
/*******************?????***************************/
#define  R_REGISTER      0x00//???????
#define  W_REGISTER      0x20//??????
#define  R_RX_PAYLOAD 	 0x61//??RX????
#define  W_TX_PAYLOAD	 0xa0//?TX????
#define  FLUSH_TX		 0xe1//??TXFIFO???
#define  FLUSH_RX		 0xe2//??RXFIFO???
#define  REUSE_TX_PL     0xe3//???????????
#define  NOP             0xff//???
/******************?????****************************/
#define  EN_AA			 0x01//??????
#define  EN_RXADDR       0x02//??????0-5???
#define  SETUP_AW        0x03//??????????3-5
#define  SETUP_RETR      0x04//??????
#define  RF_CH           0x05//??????
#define  RF_SETUP        0x06//?????
#define  STATUS          0x07//?????
#define  OBSERVE_TX      0x08//???????
#define  CD              0x09//??
#define  RX_ADDR_P0      0x0a//????0????
#define  RX_ADDR_P1      0x0b//????1????
#define  RX_ADDR_P2      0x0c//????2????
#define  RX_ADDR_P3      0x0d//????3????
#define  RX_ADDR_P4      0x0e//????4????
#define  RX_ADDR_P5      0x0f//????5????
#define  TX_ADDR         0x10//????
#define  RX_PW_P0        0x11//P0????????
#define  RX_PW_P1        0x12//P1????????
#define  RX_PW_P2        0x13//P2????????
#define  RX_PW_P3        0x14//P3????????
#define  RX_PW_P4        0x15//P4????????
#define  RX_PW_P5        0x16//P5????????
#define  FIFO_STATUS     0x17//FIFO?????
#define  FEATURE         0X1D

enum NRF_Mode {
	NRF_RX_Mode = 1,
	NRF_TX_Mode =2
};
void NRF24L01_Monitor(void);
void RX_Mode(void);
unsigned char NRF24L01_CD_Detect(void);
unsigned char NRF24L01_Read_Buf(unsigned char reg,unsigned char *pBuf,unsigned char len);
short NRF24L01_RxPacket(unsigned char *rxbuf);
unsigned char NRF24L01_TxPacket(unsigned char *txbuf);
void NRFSetTxMode(void);
void RX_Mode(void);

unsigned char NrfDump();
extern uchar Recv_Buf[32];
extern uchar Send_Buf[32];
extern enum NRF_Mode Curr_Mode;
extern int gRecvPkg;
#endif
